<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <button>打开模态框</button>
    </div>
  </body>
</html>
<script>
  //1.组件的封装
  //2.组件的通信
  //3.布局
  //4.控制元素的显示和隐藏

  // 组件 modal  弹框的组件   封装
  Vue.component("modal", {
    template: "#modal",
    props: {
      visible: {
        type: Boolean,
        default() {
          return false;
        },
      },
    },
    methods: {
      confirm() {
        this.$emit("on-confirm");
      },
    },
  });
  //
  const vm = new Vue({
    el: "#app",
    data: {
      showModal: false,
    },
    methods: {
      confirm() {
        this.showModal = false;
      },
    },
  });
</script>
